package com.demo.edit.controller;


import com.demo.edit.util.RedisRegister;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/edit")
public class EditController {

    @Autowired
    private RedisRegister redisRegister;

    @GetMapping("/open")
    private String open(@RequestParam("readOnly") Boolean readOnly, @RequestParam("username") String username, HttpServletRequest request) {
        try {
//            String fileId = request.getParameter("fileId");
            String absolutePath = "C:\\Users\\saver\\Desktop\\demo.docx";
            String register = redisRegister.register(absolutePath, "demo.docx", username, readOnly);
            return register;
        } catch (Exception e) {
            e.printStackTrace();
            return "R.error()";
        }
    }

}
